package offer;

public class offer_0054 {
    public int kthLargest(TreeNode root, int k) {
        int[] flag=new int[2];
        search(root,k,flag);
        return flag[0];
    }
    public void search(TreeNode node,int k,int[] flag){
        if(node==null) return;
        search(node.right,k,flag);
        if(flag[1]<k){
            flag[0]=node.val;
            flag[1]++;
        }
        search(node.left,k,flag);
    }
}
